// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'

import axios from 'axios'

import '../static/style/common.css'

Vue.config.productionTip = false
Vue.prototype.axios = axios

import { Tabbar, TabbarItem, Swiper,Tab, TabItem,Toast,Divider,XButton,Search,Group,Cell,ButtonTab, ButtonTabItem,Checklist,Badge,Icon,PopupPicker,XInput,XTextarea,XSwitch} from 'vux'

Vue.component('tabbar', Tabbar)
Vue.component('tabbar-item', TabbarItem)
Vue.component('swiper', Swiper)
Vue.component('tab', Tab)
Vue.component('tab-item', TabItem)
Vue.component('toast', Toast)
Vue.component('search', Search)
Vue.component('cell', Cell)
Vue.component('button-tab', ButtonTab)
Vue.component('button-tab-item', ButtonTabItem)
Vue.component('divider', Divider)
Vue.component('x-button', XButton)
Vue.component('group', Group)
Vue.component('checklist', Checklist)
Vue.component('badge', Badge)
Vue.component('icon', Icon)
Vue.component('popup-picker', PopupPicker)
Vue.component('x-input', XInput)
Vue.component('x-textarea', XTextarea)
Vue.component('x-switch', XSwitch)

//添加请求拦截器
axios.interceptors.request.use(config => {
  vm.$vux.loading.show({
    text: 'Loading'
  })
  let formData = new FormData()
  if (config.data) {
    let paylod = JSON.parse(JSON.stringify(config.data))
    for (let i in paylod) {
      formData.append(i, paylod[i])
    }
    config.data = formData
  }
  return config
},
error => {

})

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
